package com.zz.bid.mapper;

import com.zz.bid.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select id,account,pwd,groupId,admin,source,banned from op_passport where account=#{account}")
    User getUser(@Param("account") String account);

    @Select("select account,pwd,groupId,admin,source,banned,op_group.name as groupName from op_passport " +
            "left join op_group on op_group.id = op_passport.groupId")
    List<User> getUsers();

    @Insert("insert into op_passport(account,pwd,groupId,admin,banned) values(#{account},#{password},#{groupId},1,#{useAble})")
    void addUser(@Param("account") String account, @Param("password") String password, @Param("groupId") Integer groupId, @Param("useAble") Integer useAble);

    @Update("update op_passport set `pwd` = #{newPwd} where `id` = #{userId}")
    void setPwd(@Param("userId") Integer userId, @Param("newPwd") String newPwd);
}
